package com.ateam.dao.impl;

import java.util.List;

import org.mybatis.spring.SqlSessionTemplate;

import com.ateam.dao.GroupsDao;
import com.ateam.pojo.Groups;

/** 
* @author WuYuan
* 
*/
public class GroupsDaoImpl implements GroupsDao {
	private SqlSessionTemplate sqlSessionTemplate;
	
	public SqlSessionTemplate getSqlSessionTemplate() {
		return sqlSessionTemplate;
	}

	public void setSqlSessionTemplate(SqlSessionTemplate sqlSessionTemplate) {
		this.sqlSessionTemplate = sqlSessionTemplate;
	}
	
	@Override
	public int addGroup(Groups group) throws Exception {
		return sqlSessionTemplate.insert("addGroup",group);
	}

	@Override
	public int addGroupLeader(int userid, int groupid) throws Exception {
		Object [] objects =new Object[]{userid,groupid};
		return sqlSessionTemplate.insert("addGroupLeader",objects);
	}

	@Override
	public List<Groups> getGroupsByUser(int userid) throws Exception {
		return sqlSessionTemplate.selectList("getGroupsByUser",userid);
	}

	@Override
	public Groups getGroupByGroupid(int groupid) throws Exception {
		return sqlSessionTemplate.selectOne("getGroupByGroupid", groupid);
	}

}
